﻿using HospitalFollowUpSystem.DBC;
using HospitalFollowUpSystem.Entity;
using HospitalFollowUpSystem.View.FrmTopicGroup;
using MetroFramework.Forms;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace HospitalFollowUpSystem.View
{
    public partial class FrmTopic : MetroForm
    {
        private String key, value;
        public FrmTopic()
        {
            InitializeComponent();
        }

        private void itemAdd_Click(object sender, System.EventArgs e)
        {
            FrmAddTopicType type = new FrmAddTopicType();
            type.StartPosition = FormStartPosition.CenterParent;
            type.ShowDialog();

            FlushTopicList();
        }

        private void FrmTopic_Load(object sender, EventArgs e)
        {
            FlushTopicList();
        }

        private void FlushTopicList()
        {
            HRCM_DB db = new HRCM_DB();

            List<TopicGroup> list = db.GetTopicGroup();

            lvType.Items.Clear();
            foreach (TopicGroup item in list)
            {
                ListViewItem lv = new ListViewItem(item.GroupName);
                lv.Name = item.ID.ToString();
                lvType.Items.Add(lv);
            }
            if (list.Count > 0)
            {
                lvType.Items[0].Selected = true;
                lvType.Select();
                key = lvType.SelectedItems[0].Name;
                value = lvType.SelectedItems[0].Text;
                //MessageBox.Show(key + "," + value);
            }
        }

        //添加题目
        private void tsmAddQuestion_Click(object sender, EventArgs e)
        {
            FrmAddTopic topic = new FrmAddTopic(key,value);
            topic.StartPosition = FormStartPosition.CenterParent;
            topic.ShowDialog();
        }


    }
}
